#ifndef SDBUS_SERVER_H
#define SDBUS_SERVER_H

#include <mutex>
#include <sdbus-c++/sdbus-c++.h>
#include <thread>
#include <functional>

class sdbusServer
{
  public:
    //在获取初值后解除堵塞
    sdbusServer()=default;
    virtual ~sdbusServer();
    void Boot();
    std::vector<std::string> GetBufferID();
    long GetBufferSize();
    std::vector<std::string> GetCameraID();
    std::function<void(bool)> SetMobileConnectStatus;
    std::function<void(bool)> SetRecordStatus;
  private:
    void CheckInitFinish();
    std::optional<std::vector<std::string>> BufferID;
    std::optional<std::vector<std::string>> CameraID;
    std::optional<long> BufferSize;
    std::unique_ptr<sdbus::IConnection> conn;
    std::unique_ptr<sdbus::IObject> object;
    std::mutex InitMut;
    std::thread workThread;
    const char* InitInterfaceName="org.HBTY.ServerUI.Init";
    const char* MainInterfaceName="org.HBTY.ServerUI.Main";
};

#endif
